using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMBock_VehicleController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMBock_Vehicle()
        {
            return cls.BindGridData("sp_TMBock_Vehicle");
        }
        public DataTable BindGirdTMBock_Vehicle_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMBock_Vehicle_Detail_Edit", "@Block_Vehicle_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMBock_Vehicle(clsTMBock_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Block_Vehicel_Alias", data.Block_Vehicel_Alias);
            cls.AddParameter("@Block_Vehicel_Width", data.Block_Vehicel_Width);
            cls.AddParameter("@Block_Vehicel_Hight", data.Block_Vehicel_Hight);
            cls.AddParameter("@Blick_Vehicle_Length", data.Blick_Vehicle_Length);
            cls.ExecuteNonQuery("sp_TMBock_Vehicle_Insert");
            return true;
        }
        public bool UpdateTMBock_Vehicle(clsTMBock_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Block_Vehicle_ID", data.Block_Vehicle_ID);
            cls.AddParameter("@Block_Vehicel_Alias", data.Block_Vehicel_Alias);
            cls.AddParameter("@Block_Vehicel_Width", data.Block_Vehicel_Width);
            cls.AddParameter("@Block_Vehicel_Hight", data.Block_Vehicel_Hight);
            cls.AddParameter("@Blick_Vehicle_Length", data.Blick_Vehicle_Length);
            cls.ExecuteNonQuery("sp_TMBock_Vehicle_Update");
            return true;
        }
        public bool DeleteTMBock_Vehicle(int id)
        {
            cls.Delete("sp_TMBock_Vehicle_Delete", "@Id", id);
            return true;
        }
        public bool TMBock_Vehicle_Check_Delete_TMUnit_Vehicle(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMBock_Vehicle_Check_Delete_TMUnit_Vehicle", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMBock_Vehicle_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}